const express = require('express')
const { verifyToken } = require('../util/token')
const router = express.Router()


module.exports = async function (req, res, next) {
    const { token } = req.headers
    if (!token) {
        res.json({
            code: 403,
            message: 'not found token'
        })
    } else {
        try {
            await verifyToken(token)
            next()
        } catch (error) {
            res.json({
                code: 403,
                message: ''
            })
        }
    }
  
}